package com.cloud.rou.im.msg.enumtype;

import lombok.Getter;

import java.util.Arrays;

/**
 * <p></p>
 *
 * @author GaoShuangWen
 */
@Getter
public enum RecipientType {

    /**
     * SINGLE
     */
    SINGLE((byte) 1),
    /**
     * GROUP
     */
    GROUP((byte) 2);

    private byte type;

    RecipientType(byte type) {
        this.type = type;
    }

    /**
     * get the enum class
     * @param type the type
     * @return the enum class
     */
    public static RecipientType getEnum(Byte type) {
        return type == null ? null : Arrays.stream(values())
                .filter(t -> t.getType() == type)
                .findFirst()
                .orElse(null);
    }
}
